//
//  StoreManager.h
//  ebox
//  店铺数据管理
//  Created by hzm on 16-7-21.
//  Copyright (c) 2016年 custom. All rights reserved.
//

#import "StoreManager.h"
#include "HttpRequest.h"
#include "ServerMng.h"
#import "DateUtil.h"
//#import "QRStoreTableViewCell.h"
//#import "ManageMistakeTableViewCell.h"
//#import "RefundCodeAlertView.h"
#import "LoginDataMng.h"

@implementation IncomeInfo

@end


@implementation IncomeDetail

- (void)setIncomeDetail:(NSDictionary *)dic
{
    _incomeId = [AppUtils toString:dic[@"id"]];
    _time = dic[@"create_time"];
    _userName = dic[@"channel_user_name"];
    _userId = [AppUtils toString:dic[@"channel_user_id"]];
    _orderId = [AppUtils toString:dic[@"order_id"]];
    _channelNo = [AppUtils toString:dic[@"pay_interface_no"]];
    _payRequestNo = [AppUtils toString:dic[@"pay_request_no"]];
    _channelOrderId = [AppUtils toString:dic[@"channel_trade_no"]];
    _terminalName = [AppUtils toString:dic[@"terminal_name"]];
    _moneyValue = [AppUtils toString:dic[@"pay_amount"]].longLongValue;
    _refundValue = [AppUtils toString:dic[@"refund_amount"]].longLongValue;
    _payType = [AppUtils toInteger:dic[@"pay_type"]];
    _status = [AppUtils toInteger:dic[@"status"]];
    _receiptMoneyValue = [AppUtils toString:dic[@"receipt_amount"]].longLongValue;
}

-(NSString *)getStatusName
{
//    ----pay_type为支付时----1：待支付，2：已支付，3：部分退款，4：已退款，5：关闭
//    ----pay_type为退款时----1：退款处理中，2：退款成功，5：退款失败
    NSString *name = @"交易关闭";
    return name;
}

@end


@implementation OrderDetail

- (void)setOrderDetail:(NSDictionary *)dic
{
    _orderSnapshotId = [AppUtils toString:dic[@"order_snapshot_id"]];
    _creatorId = [AppUtils toString:dic[@"s_creator_id"]];
    _statusName = dic[@"status_name"];
    _name = dic[@"name"];
    _goodsList = dic[@"goods_list"];
    _createTime = dic[@"create_time"];
    _appId = [AppUtils toString:dic[@"s_app_id"]];
    _orderNo = [AppUtils toString:dic[@"order_no"]];
    _memberId = [AppUtils toString:dic[@"member_id"]];
    _totalGoods = [AppUtils toString:dic[@"total_goods"]].longLongValue;
    _orderAmount = [AppUtils toString:dic[@"order_amount"]].longLongValue;
    _payStatus = [AppUtils toInteger:dic[@"pay_status"]];
}

@end


@implementation EmployeeInfo

-(instancetype)initWithName:(NSString *)name andTerminalId:(NSString *)terminalId
{
    self = [super init];
    if(self){
        _name = name;
        _terminalId = terminalId;
    }
    return self;
    
}
- (void)setEmployeeInfo:(NSDictionary *)dic
{
    
}

-(void)setInfoByLoginUser
{
//    _employeeId = LOGIN_USER.userId;
//    _name = LOGIN_USER.name;
//    _mobile = LOGIN_USER.mobile;
//    _loginId = LOGIN_USER.userName;
//    _memberId = LOGIN_USER.loginMemberId;
//    _userRole = LOGIN_USER.userRole;
//    _userType = LOGIN_USER.userType;
//    _terminalId = LOGIN_USER.storeTerminalId;
}

-(NSArray *)getBelongStoreIds;
{
   return [AppUtils joinArrayDict:_belongStores WithKey:@"store_id"];
}

-(NSString *)getUserRoleStr
{
    NSString *text = @"";
   
    return text;
}


- (void)copyBaseInfo:(EmployeeInfo *)info
{
    
}

-(void)resetBelongStore:(NSArray *)stores
{
    [_belongStores removeAllObjects];
    if([AppUtils isEmptyArray:stores]){
        return;
    }
    [_belongStores addObjectsFromArray:stores];
}


@end


@implementation AdInfo

- (void)setAdInfo:(NSDictionary *)dic
{
    if (nil == dic || ![dic isKindOfClass:[NSDictionary class]]) {
        return;
    }
    if (nil != dic[@"id"]) {
        _linkUrl = [NSString stringWithFormat:@"%@/cod/article/%@", HTTP_DOMAIN_H5, [AppUtils toString:dic[@"id"]]];
    }
    if (nil != dic[@"title"]) {
        _title = [AppUtils toString:dic[@"title"]];
    }
    if (nil != dic[@"image_url"]) {
        _imageUrl = [AppUtils toString:dic[@"image_url"]];
    }
}

@end



@interface StoreManager()

@property (nonatomic, retain) NSDictionary *orderInfo;

@end

@implementation StoreManager

+ (instancetype)sharedInstance
{
    static StoreManager *instance;
    static dispatch_once_t pred;
    dispatch_once(&pred, ^{
        instance = [[StoreManager alloc] init];
        [instance initData];
    });
    return instance;
}

- (void)initData
{
    _employee = [[EmployeeInfo alloc] init];
    [_employee setEmployeeInfo:nil];
}

@end
